<?php echo "<?php" ?>

{{$dollar}}base_columns = [
    @if(isset($meta))
        @if(isset($meta[$resource]))

                @if(isset($meta[$resource]["columns"]))
                    @foreach($meta[$resource]["columns"] as $column)
                        [
                            "field" => "{{$column['name']}}"
                            , "type" => "{{$column['type']}}"
                            , "rules" => "{{$column['rules']}}"
                            , "required" => {{$column['required']}}
                            , "description" => "{{$column['comment']}}"
                        ],
                    @endforeach
                @endif

        @endif
    @endif
];

return [
    "group" => "default",
    "controller" => "App\\Http\\Controllers\\{{$controller}}Controller",
    "description" => "{{$resource}} 基本接口",
    "resource" => "{{$resource}}",
    "methods" => [
        [
            "middleware" => ["oauth"],
            "method" => "grid",
            "privileges" => ["{{$resource}}.view"],
            "requestRoute" => "{{$route}}/grid",
            "description" => "管理 {{$resource}}",
            "inputs" => [
                [
                    "field" => "page"
                    , "rules" => "numeric"
                    , "description" => "页码（第几页），默认为1"
                ],
                [
                    "field" => "page_size"
                    , "rules" => "numeric"
                    , "description" => "翻页大小，默认=10"
                ]
            ],
            "outputs" => {{$dollar}}base_columns ,
            "errors" => [
            ]
        ],
        [
            "middleware" => ["oauth"],
            "method" => "edit",
            "privileges" => ["{{$resource}}.edit"],
            "requestRoute" => "{{$resource}}/edit",
            "description" => "创建 {{$resource}}",
            "inputs" => {{$dollar}}base_columns ,
            "outputs" => {{$dollar}}base_columns ,
            "errors" => [
            ]
        ],
        [
            "middleware" => ["oauth"],
            "method" => "detail",
            "privileges" => ["{{$resource}}.view"],
            "requestRoute" => "{{$resource}}/detail",
            "description" => "获取 {{$resource}}",
            "inputs" => [
            ],
            "outputs" => {{$dollar}}base_columns ,
            "errors" => [
                [
                    "code" => "record.not.found"
                    , "message" => "没有找到记录"
                ]
            ]
        ],
        [
            "middleware" => ["oauth"],
            "method" => "delete",
            "privileges" => ["{{$resource}}.kill"],
            "requestRoute" => "{{$resource}}/delete",
            "description" => "删除 {{$resource}}",
            "inputs" => [
                [
                     "field" => "{{$primary_key}}"
                    , "type" => ""
                    , "rules" => "required|integer"
                    , "required" => 1
                    , "description" => ""
                ],
            ],
            "outputs" => [
            ],
            "errors" => [
                [
                    "code" => "record.used"
                    , "message" => "记录已经被使用，存在重要数据，无法删除"
                ]
            ]
        ]
    ]
];